package ai.people.netmon.framework.domain.archives.vo;

import ai.people.netmon.framework.domain.archives.entity.GangGroupInfo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import com.people.core.validator.annotation.SourcesValue;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * 团伙基本详情
 * @author zhenglin
 * @date 2022/6/21
 */
@Data
@NoArgsConstructor
public class GangGroupInfoVO{
    /**
     * 团伙名称
     */
    @NotNull(message = "团伙名称不能为空")
    @Size(min = 1, message = "团伙名称不能为空")
    private List<String> groupName;

    /**
     * 团伙照片
     */
    private List<String> groupPicture;

    /**
     * 活动地区
     */
    private List<String> activeRegion;

    /**
     * 团伙人数
     */
    private String groupPeopleCount;

    /**
     * 危险程度
     */
    @JSONField(serializeUsing = ToStringSerializer.class)
    private Integer degreeOfDanger;

    /**
     * 标签
     */
    private List<String> tags;

    /**
     * 团伙创建者
     */
    private String groupCreator;

    /**
     * 现任首领
     */
    private String groupChief;

    /**
     * 团伙成立时间
     */
    private String groupCreateTime;

    /**
     * 团伙总部
     */
    private String groupHeadquarters;

    /**
     * 团伙信仰
     */
    private String groupFaith;

    /**
     * 团伙账号信息
     */
    private List<GroupSocial> groupSocial;

    /**
     * 团伙简介
     */
    private String groupBrief;

    /**
     * 团伙目标
     */
    private String groupGoal;

    /**
     * 研判意见
     */
    private String judgment;

    public GangGroupInfoVO(GangGroupInfo gangGroupInfo) {
        this.groupName = gangGroupInfo.buildGroupNameList();
        this.groupPicture = gangGroupInfo.buildGroupPictureList();
        this.activeRegion = gangGroupInfo.buildActiveRegionList();
        this.groupPeopleCount = gangGroupInfo.getGroupPeopleCount();
        this.degreeOfDanger = gangGroupInfo.getDegreeOfDanger();
        this.tags = gangGroupInfo.buildTagsList();
        this.groupCreator = gangGroupInfo.getGroupCreator();
        this.groupChief = gangGroupInfo.getGroupChief();
        this.groupCreateTime = gangGroupInfo.getGroupCreateTime();
        this.groupHeadquarters = gangGroupInfo.getGroupHeadquarters();
        this.groupFaith = gangGroupInfo.getGroupFaith();
        this.groupSocial = gangGroupInfo.buildGroupSocialList();
        this.groupBrief = gangGroupInfo.getGroupBrief();
        this.groupGoal = gangGroupInfo.getGroupGoal();
        this.judgment = gangGroupInfo.getJudgment();
    }

    public String buildNameStr(){
        if (CollectionUtils.isNotEmpty(this.groupName)){
            return StringUtils.join(this.groupName, ",");
        }
        return null;
    }

    public String buildPictureStr() {
        if (CollectionUtils.isNotEmpty(this.groupPicture)){
            return StringUtils.join(this.groupPicture, ",");
        }
        return null;
    }

    public String buildActiveRegionStr() {
        if (CollectionUtils.isNotEmpty(this.activeRegion)){
            return StringUtils.join(this.activeRegion, ",");
        }
        return null;
    }

    public String buildTagsStr() {
        if (CollectionUtils.isNotEmpty(this.tags)){
            return StringUtils.join(this.tags, ",");
        }
        return null;
    }

    public String buildGroupSocialJSONStr() {
        if (CollectionUtils.isNotEmpty(this.groupSocial)){
            return JSON.toJSONString(this.groupSocial);
        }
        return null;
    }

    @Data
    public static class GroupSocial{
        @NotBlank(message = "社交平台不能为空")
        @SourcesValue
        @Length(max = 255, message = "社交平台长度最长为{max}")
        private String socialPlatform;

        /**
         * 头像
         */
        private String portrait;

        /**
         * 昵称
         */
        @Length(max = 255, message = "昵称长度最长为{max}")
        private String nickName;

        /**
         * 账号
         */
        @Length(max = 255, message = "账号长度最长为{max}")
        @NotBlank(message = "账号不能为空")
        private String username;
        /**
         * ID
         */
        @Length(max = 255, message = "账号ID长度最长为{max}")
        private String accountId;
        /**
         * url
         */
        private String url;
        /**
         * 简介
         */
        private String brief;
    }



}
